package study;

import org.w3c.dom.ls.LSOutput;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @since:
 * @ClassName:HashMapTest
 * @author: Li Jiahui
 * @date: 2021-05-05 23:22
 */
public class HashMapTest {
    public static void main(String[] args) {
        //1.准备一个HashMap集合并打印
        Map<String, String> m1 = new HashMap<>();
        System.out.println("m1 = " + m1);
        //2.向集合中添加元素并打印
        String str1 = m1.put("1","one");
        System.out.println("原来的value数值为：" + str1);
        System.out.println("m1 = " + m1);

        str1 = m1.put("2","two");
        System.out.println("原来的value数值为：" + str1);
        System.out.println("m1 = " + m1);

        str1 = m1.put("3","there");
        System.out.println("原来的value数值为：" + str1);
        System.out.println("m1 = " + m1);

        str1 = m1.put("1","eleven");
        System.out.println("原来的value数值为：" + str1);
        System.out.println("m1 = " + m1);

        System.out.println("----------");
        //3.实现查找功能的操作
        boolean b1 = m1.containsKey("1");
        System.out.println("有找到的Key:" +b1);
        String str2 = m1.get(5);
        System.out.println(str2);
    }


}
